package com.xiongwei.status;

/**
 * 抽奖活动
 * @author XiongWei
 * @date 2024/2/19
 */
public class RaffleActivity {

    /**
     * 活动状态
     */
    private State state;

    /**
     * 奖品数量
     */
    private int count;

    /**
     四种属性，表示四种状态
     */
    State noRaffleState = new NoRaffleState(this);
    State raffleState = new RaffleState(this);

    State dispensePrizeState = new DispensePrizeState(this);
    State dispensePrizeOutState = new DispensePrizeOutState(this);

    /**
     * 初始化状态为不能抽奖状态,奖品数量为0
     */
    public RaffleActivity(int count) {
        this.state = noRaffleState;
        this.count = count;
    }

    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    /**
     * 扣分
     */
    public void deductPoint() {
        state.deductPoint();
    }

    /**
     * 抽奖
     */
    public void raffle() {
        if (state.raffle()) {
            state.dispensePrize();
        }
    }

    /**
     * 获取奖品总数
     */
    public int getCount() {
        //int currentCount = count;
        //count--;
        //return currentCount;
        return count--;
    }

    /**
     * 设置奖品总数
     * @param count
     * @return
     */
    public void setCount(int count) {
        this.count = count;
    }

    public State getNoRaffleState() {
        return noRaffleState;
    }

    public void setNoRaffleState(State noRaffleState) {
        this.noRaffleState = noRaffleState;
    }

    public State getRaffleState() {
        return raffleState;
    }

    public void setRaffleState(State raffleState) {
        this.raffleState = raffleState;
    }

    public State getDispensePrizeState() {
        return dispensePrizeState;
    }

    public void setDispensePrizeState(State dispensePrizeState) {
        this.dispensePrizeState = dispensePrizeState;
    }

    public State getDispensePrizeOutState() {
        return dispensePrizeOutState;
    }

    public void setDispensePrizeOutState(State dispensePrizeOutState) {
        this.dispensePrizeOutState = dispensePrizeOutState;
    }
}
